package cn.wolfcode.p2p.controller;

import cn.wolfcode.p2p.base.service.IAccountService;
import cn.wolfcode.p2p.base.service.IUserInfoService;
import cn.wolfcode.p2p.base.util.UserContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class BorrowController {

    @Autowired
    private IAccountService accountService;

    @Autowired
    private IUserInfoService userInfoService;

    @RequestMapping("/borrow")
    public String borrowPage(Model model){
        if(UserContext.getCurrent() == null){
            //跳转到一个空白的页面
            return "redirect:/borrowIndex.html";
        }
        model.addAttribute("account",accountService.get(UserContext.getCurrent().getId()));
        model.addAttribute("userInfo",userInfoService.get(UserContext.getCurrent().getId()));
        return "borrow";
    }
}
